﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

using System.Runtime.Serialization;
using System.ServiceModel.Web;

// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IBookService" in both code and config file together.
[ServiceContract]
public interface IBookService
{

    [OperationContract]
    [WebGet(UriTemplate = "getcategories", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)]
    ServiceListCategory GetListCategory();

    [OperationContract]
    [WebGet(UriTemplate = "getbook?categoryid={categoryId}&type={typeId}&account={account}&pageSize={pageSize}&pagenumber={pageNumber}", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)]
    ServiceListBook GetBook(long categoryId, int pageSize, int pageNumber, int typeId, string account);
    
    [OperationContract]
    [WebGet(UriTemplate = "searchbook?keyword={keyWord}&pageSize={pageSize}&pagenumber={pageNumber}", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)]
    ServiceListBook SearchBook(string keyWord, int pageSize,int pageNumber);

    [OperationContract]
    [WebGet(UriTemplate = "downloadbook?session={session}&bookid={bookId}", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)]
    string DownloadBook(string session, long bookId);

    [OperationContract]
    [WebGet(UriTemplate = "ratebook?rate={rate}&bookid={bookId}", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)]
    bool RateBook(int rate,long bookId);
}

public class ServiceListCategory
{
    [DataMember]
    public Dictionary<string,string> Results { set; get; }
}

public class ServiceListBook
{
    [DataMember]
    public List<BookEntity2> Results { set; get; }

    [DataMember]
    public int resultCount { set; get; }
}

public class ServiceListPlatform
{
    [DataMember]
    public List<PlatformEntity> Results { set; get; }
    [DataMember]
    public int resultCount { set; get; }
}

[DataContract]
public class UserLogin
{
    [DataMember]
    public string Message { get; set; }
    [DataMember]
    public string DevideName { get; set; }
    [DataMember]
    public string UserToken { get; set; }
    [DataMember]
    public bool Results { set; get; }

}